package com.kotlin.zds.activity

import android.view.LayoutInflater
import android.view.View
import com.kotlin.zds.MainActivity
import com.kotlin.zds.base.BaseActivity
import com.kotlin.zds.databinding.ActivityWelcomBinding
import com.kotlin.zds.ext.startNewActivity
import com.kotlin.zds.utils.XToastUtils
import com.xuexiang.xui.utils.StatusBarUtils
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch


/**
 * Author: zds
 * Date: 2022/6/10 20:54
 * Description:
 * Version: v1.0
 */
class WelcomActivity:BaseActivity() {
    private lateinit var job: Job
    val viewBinding by lazy {
        ActivityWelcomBinding.inflate(LayoutInflater.from(mActivity))
    }
    override fun onSetContentView() {
        StatusBarUtils.translucent(this)
        setContentView(viewBinding.root)
    }


    override fun initView() {
        job= GlobalScope.launch {
            delay(2000)
            startNewActivity(MainActivity::class.java)
            finish()
        }
    }

    override fun initData() {
        viewBinding.run {
            tvVersion.setOnClickListener(mOnClickListener)
        }
    }

    override fun onViewClick(v: View) {
        when(v){
            viewBinding.tvVersion ->{XToastUtils.success("bane")}
        }
    }

    override fun onDestroy() {
        super.onDestroy()
        job.cancel()
    }
}